/**
 * 弹窗hooks
 * @Author: linzy
 * @Date: 2022-06-23
 * @function useModal
 * @property {} props - 默认值： <br />
 * centered: true, <br />
    onCancel() {
      visibleSet(false);
    }, <br />
    bodyStyle: { maxHeight: "80vh", overflowY: "auto" } <br />
 * @returns [Modal, modalProps, setVisible]
 * @example
 const [Modal, modalProps, setVisible] = useModal()
<Modal {...modalProps}></Modal>
*/
import { Modal } from "antd";
import { useState } from "react";
import { setDefaultAttrs } from "@/hooks/tools";

export default (props = {}) => {
  const [visible, visibleSet] = useState(false);
  setDefaultAttrs(props, {
    visible,
    centered: true,
    onCancel() {
      visibleSet(false);
    },
    bodyStyle: { maxHeight: "80vh", overflowY: "auto" },
  });
  return [Modal, props, visibleSet];
};
